/*
 * File:   config_file.c
 * Author: onteria_
 *
 * Created on April 30, 2011, 7:11 AM
 */

#include "config_file.h"

Config parse_config(const char * path) {
    
    Config program_options = {0};
    
    program_options.error_flag = -1;
    
    cfg_opt_t opts[] = {
        CFG_SIMPLE_STR("server_ipv4", &program_options.server_ipv4),
        CFG_SIMPLE_STR("server_ipv6", &program_options.server_ipv6),
        CFG_SIMPLE_INT("port_ipv4", &program_options.port_ipv4),
        CFG_SIMPLE_INT("port_ipv6", &program_options.port_ipv6),
        CFG_SIMPLE_INT("timeout", &program_options.timeout),
        CFG_SIMPLE_INT("total_ipv4_connections", &program_options.total_ipv4_connections),
        CFG_SIMPLE_INT("total_ipv6_connections", &program_options.total_ipv6_connections),
        CFG_SIMPLE_INT("max_content_length", &program_options.max_content_length),
        CFG_SIMPLE_INT("ipv6", &program_options.ipv6),
        CFG_END()
    };
    cfg_t *cfg;

    cfg = cfg_init(opts, 0);
    cfg_parse(cfg, path);
    cfg_free(cfg);
    
    return program_options;
}
